//index.js
//获取应用实例
const app = getApp()
Page({
  data: {
    imgUrls: [
              'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
              'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
              'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    circular:true,
    interval: 3000,
    duration: 500,
    navLists: [
      {
        id:'0',
        title:"推荐",
        imgUrl:"http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg",
      },
      {
        id: '1',
        title: "美甲",
        imgUrl: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg",
      },
      {
        id: '2',
        title: "美容",
        imgUrl: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg",
      },
      {
        id: '3',
        title: "美发",
        imgUrl: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg",
      },
      {
        id: '4',
        title: "美睫",
        imgUrl: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg",
      },
    ],
    contentList:[
      {
        id:'1',
        imgUrl:'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
        title:'秋季特价美甲秋季特价美甲秋季特价美甲秋季特价美甲秋季特价美甲秋季特价美甲',
        price:'188',
        langer:'我们追求卓美我们追求卓美我们追求卓美'
      }
    ],
    currentTab:0,
    scrollTop: 0,
    isDisplay:false
  },
  //滑动切换样式
  switchTab:function(e){
    this.setData({
      currentTab: e.detail.current
    });
  },
  //点击切换文字样式
  swichNav:function(e){
    let cur = e.currentTarget.dataset.current;
    if (this.data.currentTaB == cur) { 
      return false;
    }else{
      this.setData({
        currentTab: cur
      })
    }
  },
  //高度自适应
  onLoad: function () {
    var that = this;
    let arr = [];
    for(let i = 0; i< 10;i++){
      arr.push(this.data.contentList[0])
    }
    this.setData({
      contentList:arr
    })
    let cliHeight = arr.length * 101;
    that.setData({
      cliHeight: cliHeight
    });  
  },
  onPageScroll: function (e) {
    if (e.scrollTop > 500){
      this.setData({ isDisplay: true})
    }else{
      this.setData({ isDisplay: false })
    }
  },
   //返回顶部
  onTop: function (e) {
    wx.pageScrollTo({
      scrollTop: 0
    })
  },
  //跳转详情页
  goDetail:function(e){
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../detail/detail?id=' + id,
    })
  }
})
